function OCTgeturlparam(param) { var urlParams = new URLSearchParams(window.location.search); return urlParams.get(param) !== null ? param+'='+urlParams.get(param) : ''; } var OCT4_GET_LANG = ''; var prdoptmltcol_ur1201 = 'index.php?route=module/prdoptmltcol/'; var prdoptmltcol_url230 = 'index.php?route=extension/module/prdoptmltcol/'; var prdoptmltcol_url401 = 'index.php?route=extension/prdoptmltcol/module/prdoptmltcol|'; var prdoptmltcol_url402 = 'index.php?route=extension/prdoptmltcol/module/prdoptmltcol.'; var prdoptmltcol = { 'atgrid': function() { var product_ids = []; $("[onclick*='cart.add'], [onclick*='addToCart'], .product-thumb form input[name='product_id']").each(function() { if($(this).closest('form').find("[name*='product_id']").length) { var target = $(this).closest('.product-thumb, .product-wrapper'); var product_id = $(this).val(); } else { var target = $(this).closest('.product-thumb, .product-wrapper'); var product_id = $(this).attr('onclick').match(/[0-9]+/).toString(); } if(target.length && target.hasClass('prdoptmltcol_atgrid') == false) { target.addClass('prdoptmltcol_atgrid').addClass('prdoptmltcol_atgrid'+product_id); product_ids.push(product_id); } }); if(product_ids.length) { //console.log(product_ids.length); $.ajax({ url: prdoptmltcol_url230 + 'getcache' + OCT4_GET_LANG, type: 'post', data: {product_ids:product_ids}, cache: true, complete: function() { }, success: function(json) { if(json && json['grid']) { //console.log(json); $("[onclick*='cart.add'], [onclick*='addToCart'], .product-thumb form input[name='product_id']").each(function() { if($(this).closest('form').find("[name*='product_id']").length) { var target = $(this).closest('.product-thumb, .product-wrapper'); var product_id = $(this).val(); } else { var target = $(this).closest('.product-thumb, .product-wrapper'); var product_id = $(this).attr('onclick').match(/[0-9]+/).toString(); } if(json['grid'][product_id] && target.length && target.hasClass('prdoptmltcol') == false) { target.addClass('prdoptmltcol').find('.price').after(json['grid'][product_id].join("")); } }); } } }); } }, 'prodpage': function() { var product_ids = []; var product_id = false; if($(".button-group-page input[name='product_id']").length) { product_id = $(".button-group-page input[name='product_id']").val(); product_ids.push(product_id); } else if($('#input-product-id').length) { product_id = $('#input-product-id').val(); product_ids.push(product_id); } else if($(".product-info input[name='product_id']").length) { product_id = $(".product-info input[name='product_id']").val(); product_ids.push(product_id); } else if($("#product input[name='product_id']").length) { product_id = $("#product input[name='product_id']").val(); product_ids.push(product_id); } if (product_ids.length) { $.ajax({ url: prdoptmltcol_url230 + 'getcache' + OCT4_GET_LANG, type: 'post', data: {product_ids:product_ids}, cache: true, complete: function() { }, success: function(json) { if(json && json['prdpg']) { var target = $('#product .form-group').eq(0); var target_OC4 = $('#product .mb-3').eq(0); var target_J2 = $('#product .form-group').eq(0); var target_J3 = $('.button-group-page'); if(json['prdpg'][product_id]) { if(target.length && target.hasClass('prdoptmltcol') == false) { target.addClass('prdoptmltcol').before(json['prdpg'][product_id].join("")); } if(target_J2.length && target_J2.hasClass('prdoptmltcol') == false) { target_J2.addClass('prdoptmltcol').before(json['prdpg'][product_id].join("")); } if(target_J3.length && target_J3.hasClass('prdoptmltcol') == false) { target_J3.addClass('prdoptmltcol'); if($('.product-options h3.options-title').length) { $('.product-options h3.options-title').after(json['prdpg'][product_id].join("")); } else { target_J3.before('
' + json['prdpg'][product_id].join("") + '
'); } } if(target_OC4.length && target_OC4.hasClass('prdoptmltcol') == false) { target_OC4.addClass('prdoptmltcol').before(json['prdpg'][product_id].join("")); } } } } }); } }, 'initjson': function() { prdoptmltcol.atgrid(); $(document).ajaxStop(function() { prdoptmltcol.atgrid(); }); prdoptmltcol.prodpage(); } } $(document).ready(function() { prdoptmltcol.initjson(); // FOR GRID LIST $(document).delegate('.prdoptmltcol_radio_griddiv', 'click', function() { if($(this).find('input[type="checkbox"]').length) { if($(this).find('input[type="checkbox"]').prop('checked')) { $(this).find('.prdoptmltcol_atgrid').removeClass('act'); $(this).find('input[type="checkbox"]').prop("checked",false).trigger('change'); } else { $(this).find('.prdoptmltcol_atgrid').addClass('act'); $(this).find('input[type="checkbox"]').prop("checked",true).trigger('change'); } } else { $(this).closest('.form-group, .mb-3').find('.act').removeClass('act'); $(this).find('.prdoptmltcol_atgrid').addClass('act'); $(this).find('input[type="radio"]').prop("checked",true).trigger('change'); } var grdimg = $(this).find('.prdoptmltcol_swpimggrd').val(); var target = $(this).closest('.product-thumb, .product-wrapper').find('.image'); if(grdimg != '') { target.find('img.img-responsive, img.img-fluid, img.first-image').attr('src', grdimg); target.find('img.img-responsive, img.img-fluid, img.first-image').attr('srcset', grdimg); target.find('img.img-responsive, img.img-fluid, img.first-image').parent().removeClass('has-second-image'); } }); $(document).delegate('.prdoptmltcol_gridbtnrst', 'click', function() { $(this).closest('.form-group, .mb-3').find('.act').removeClass('act'); $(this).closest('.form-group, .mb-3').find('input.prdoptmltcol_radio_input').prop("checked",false).trigger('change'); var orgimg = $(this).closest('.form-group, .mb-3').find('.prdoptmltcol_orgimggrd').val(); var target = $(this).closest('.product-thumb, .product-wrapper').find('.image'); target.find('img.img-responsive, img.img-fluid, img.first-image').attr('src', orgimg); target.find('img.img-responsive, img.img-fluid, img.first-image').attr('srcset', orgimg); target.find('img.img-responsive, img.img-fluid, img.first-image').parent().removeClass('has-second-image'); }); // FOR Product Details Page $(document).delegate('.prdoptmltcol_radio_prdpgdiv', 'click', function() { if($(this).find('input[type="checkbox"]').length) { if($(this).find('input[type="checkbox"]').prop('checked')) { $(this).find('.prdoptmltcol_atprd').removeClass('act'); $(this).find('input[type="checkbox"]').prop("checked",false).trigger('change'); } else { $(this).find('.prdoptmltcol_atprd').addClass('act'); $(this).find('input[type="checkbox"]').prop("checked",true).trigger('change'); } } else { $(this).closest('.form-group, .mb-3').find('.act').removeClass('act'); $(this).find('.prdoptmltcol_atprd').addClass('act'); $(this).find('input[type="radio"]').prop("checked",true).trigger('change'); } if($(this).find('.prdoptmltcol_atprd').attr('data-original-title')) { $(this).closest('.form-group, .mb-3').find('.prdoptmltcol_showtitle').remove(); $(this).closest('.form-group, .mb-3').find('label').after('
'+$(this).find('.prdoptmltcol_atprd').attr('data-original-title')+'
'); } // Additional Image swapper var col_addimg = $(this).find('.prdoptmltcol_addimg').val(); var col_addimg_pop = $(this).find('.prdoptmltcol_addimgpop').val(); //add by bousalem var col_addsku = $(this).find('.prdoptmltcol_sku').val(); $('.product-sku').html('SKU:'+col_addsku+''); //alert(col_addsku); // //add by bousalem var col_addquantity = $(this).find('.prdoptmltcol_quantity').val(); //$('.product-sku').html('SKU:'+col_addsku+''); //alert(col_addquantity); if(col_addquantity <= 0) { $('#button-cart').hide(); $('#button-extra').hide(); $('#button-outcart').show(); }else { $('#button-cart').show(); $('#button-extra').show(); $('#button-outcart').hide(); } // prdoptmltcol_imgswap_addimg(col_addimg, col_addimg_pop); // Main image swapper var prdimg = $(this).find('.prdoptmltcol_swpimgprd').val(); var prdimgpop = $(this).find('.prdoptmltcol_swpimgpopprd').val(); //alert('prdimg : '+prdimg); //prdoptmltcol_imgswapper(prdimg, prdimgpop); if(prdimg != '') { prdoptmltcol_imgswapper(prdimg, prdimgpop); } }); $(document).delegate('.prdoptmltcol_prdpg_btnrst', 'click', function() { $(this).closest('.form-group, .mb-3').find('.act').removeClass('act'); $(this).closest('.form-group, .mb-3').find('input.prdoptmltcol_radio_input').prop("checked",false).trigger('change'); $(this).closest('.form-group, .mb-3').find('.prdoptmltcol_showtitle').remove(); // Additional Image swapper $('li.image-additional, .div.image-additional, .div.additional-image, #product-info .magnific-popup div a').removeClass('prdoptmltcol_hide_addimg'); $('.col_addimg').remove(); // Main image swapper var prdimg = $(this).closest('.form-group, .mb-3').find('.prdoptmltcol_orgimgprd').val(); var prdimgpop = $(this).closest('.form-group, .mb-3').find('.prdoptmltcol_orgimgpopprd').val(); if(prdimg != '') { prdoptmltcol_imgswapper(prdimg, prdimgpop); } }); }); function prdoptmltcol_imgswapper(prdimg, prdimgpop) { //alert(prdimg+' '+prdimgpop); // J3 if($('.product-left .main-image .swiper-slide-active').length) { target = $('.product-left .main-image .swiper-slide-active'); target.find('img').attr('src', prdimg); target.find('img').attr('srcset', prdimgpop); target.find('img').attr('data-zoom-image', prdimgpop); target.find('img').attr('data-largeimg', prdimgpop); $('.zoomWindowContainer div').stop().css("background-image","url("+ JSON.stringify(String(prdimgpop)) +")"); $(document).delegate('.additional-image', 'click', function () { //alert('click'); $('.additional-image').removeClass('swiper-slide-active'); $(this).addClass('swiper-slide-active'); var $s = $('.main-image').data('swiper'); if ($s.params.loop) { $s.slideToLoop($(this).data('index'), 0); } else { $s.slideTo($(this).data('index'), 0); } }); $('.main-image img').each(function () { var $this = $(this); $this.ImageZoom({ type: Journal['isPopup'] ? Journal['quickviewPageStyleCloudZoomPosition'] : Journal['productPageStyleCloudZoomPosition'], showDescription: false, offset: [0, 0], zoomSize: [$this.width(), $this.height()], bigImageSrc: $this.data('largeimg') }); }); } target = $('ul.thumbnails li:first-child a'); if($('.product-info #image').length) { // J2 target = $('.product-info #image').parent(); } if($('#product-info .magnific-popup').length) { // OC4 target = $('#product-info .magnific-popup a:eq(0)'); } target.find('img').attr('src', prdimg); target.attr('href', prdimgpop); target.find('img').attr('data-zoom-image', prdimgpop); $('.zoomWindowContainer div').stop().css("background-image","url("+ JSON.stringify(String(prdimgpop)) +")"); $('.zm-viewer img').attr('src', prdimgpop); setTimeout(function(){ $('.zm-viewer img').attr('src', prdimgpop); }, 1000); } function prdoptmltcol_imgswap_addimg(col_addimg, col_addimg_pop) { if(col_addimg) { col_addimg = col_addimg.split(","); col_addimg_pop = col_addimg_pop.split(","); if($('li.image-additional').length) { $('li.image-additional').addClass('prdoptmltcol_hide_addimg'); $('.col_addimg').remove(); for (var cnt = 0; cnt < col_addimg.length; cnt++) { if(col_addimg[cnt] != '') { $('ul.thumbnails li:first-child a').closest('ul').append('
  • '); } } } // OC4 if($('#product-info .magnific-popup div').length) { $('#product-info .magnific-popup div a').addClass('prdoptmltcol_hide_addimg'); $('.col_addimg').remove(); for (var cnt = 0; cnt < col_addimg.length; cnt++) { if(col_addimg[cnt] != '') { $('#product-info .magnific-popup div').append(' '); } } } // J2 if($('.product-info #image').length) { $('div.image-additional .swiper-slide').addClass('prdoptmltcol_hide_addimg'); $('.col_addimg').remove(); for (var cnt = 0; cnt < col_addimg.length; cnt++) { if(col_addimg[cnt] != '') { $('div.image-additional .swiper-wrapper').append(' '); } } } // J3 if($('.product-left .main-image .swiper-slide-active').length) { //if($('.product-left .main-image').length) { //alert('ok'); $('div.additional-image').addClass('prdoptmltcol_hide_addimg'); $('.col_addimg').remove(); //$('.additional-image').removeClass('swiper-slide-active'); //$('.product-left .main-image .swiper-wrapper').removeClass('swiper-slide-visible').removeClass('swiper-slide-active'); var addimg_html = ''; var addimg_html_slider = ''; var active = 'swiper-slide-visible swiper-slide-active'; for (var cnt = 0; cnt < col_addimg.length; cnt++) { //alert(col_addimg[cnt]); if(col_addimg[cnt] != '') { random_index = cnt + (parseInt($(".additional-image").length));//Math.floor(Math.random() * 100 * 100); addimg_html += '
    '; addimg_html_slider += '
    '; if(active != '') { active = ''; } } } //alert(addimg_html_slider); $('.additional-images .swiper-container .swiper-wrapper').append(addimg_html); $('.product-left .main-image .swiper-wrapper').append(addimg_html_slider); //$('.product-left .main-image .swiper-wrapper').removeClass('swiper-slide-visible').removeClass('swiper-slide-active'); $('.product-left .main-image .swiper-wrapper').removeClass('swiper-slide-visible'); $('.product-left .main-image .swiper-wrapper').removeClass('swiper-slide-active'); } } }